#!/usr/bin/perl

use warnings;
use strict;

my @floats = qw{1.12 2.45 5.89};
my $avg = average(@floats);
printf "Average: %.2f\n", $avg;

sub average {
    my @numbers = @_;
    my $sum = 0;
    foreach (@numbers) {
        $sum += $_;
    }
    my $average = $sum / ($#numbers + 1);
}
